home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 3.6 KB | 98 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
- { UBusyCursor.p }
- { Copyright © 1985-1990 Apple Computer, Inc. All rights reserved. }
- {[f-]}
- {
- T H E O R Y O F O P E R A T I O N
-
- The UBusyCursor unit implements a mechanism for automatically setting
- the cursor to the watch when the application is "busy."
-
- An application is considered "busy" if it hasn't called GetNextEvent
- or EventAvail for a given number of ticks, where 60 ticks equals one
- second. The default time is defined by kWatchDelay, which is 120 ticks
- or 2 seconds--it can be changed by calling BusyDelay. After this period
- of time has elapsed with no call to GetNextEvent or EventAvail, the
- cursor is changed to the watch. On the next call to GetNextEvent or
- EventAvail, the cursor is restored to its state before it was changed to
- the watch.
-
- Changing the cursor to the watch is done by the VBL task AWatchTask.
- AWatchTask's execution frequency is set to kWatchDelay, or by calling
- BusyDelay. When AWatchTask is executed it sets the cursor to the
- watch and resets AWatchTask's vblCount.
-
- The traps InitCursor, SetCursor and SetCCursor are patched so that
- they "remember" the cursor being set before executing the trap. This
- will allow us to restore the cursor after it has been changed to the
- busy watch.
-
- The EventAvail and GetNextEvent traps are patched such that, before
- executing the trap, AWatchTask's vblCount is reset, and if the busy
- cursor is displayed, then the cursor is restored to the last cursor
- set by SetCursor or SetCCursor.
- }
- {[f+]}
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := FALSE}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT UBusyCursor;
-
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED __UBusyCursor__}
- {$SETC __UBusyCursor__ := FALSE}
- {$ENDC}
-
- {$IFC NOT __UBusyCursor__}
- {$SETC __UBusyCursor__ := TRUE}
-
- { • Auto-Include the requirements for this unit's interface. }
- {$SETC UBusyCursorIncludes := UsingIncludes}
- {$SETC UsingIncludes := TRUE}
- {$I+}
- {$IFC UNDEFINED UsingTypes} {$I Types.p} {$ENDC}
- {$SETC UsingIncludes := UBusyCursorIncludes}
-
- CONST
- kWatchDelay = 2 * 60; {default # of 1/60 sec. ticks before cursor
- changes to a watch}
-
- PROCEDURE InitUBusyCursor;
- { Initialize the unit. }
-
- PROCEDURE BusyActivate(entering: BOOLEAN);
- { Call BusyActivate if you want to activate or deactivate the busy cursor mechanism. This is
- call by MacApp when losing/gaining control to a desk accessory or switcher partition. }
-
- PROCEDURE BusyDelay(newDelay: INTEGER);
- { Call BusyDelay if you want to change the busy cursor delay. newDelay should be in 1/60
- seconds; a value <= 0 means don't change the cursor. (BusyDelay respects the state flags
- in the cursor info record (ie., changeToWatch and inControl.) }
-
- PROCEDURE ForceBusy;
- { Puts up the watch immediately }
-
- PROCEDURE ResetBusyCursor;
- { Call ResetBusyCursor if you want to change the cursor back to an arrow and reset the time
- before changing back to a watch. This is not usually called directly by the application.
- Instead, it is called each time GetNextEvent and EventAvail is called, by patches installed
- by BusyInstall. }
-
- PROCEDURE BusyInstall;
- { BusyInstall installs the busy cursor mechanism. Typically this is called once during
- program initialization. It installs the VBL task and patches the traps GetNextEvent,
- EventAvail, InitCursor, SetCursor and SetCCursor. }
-
- PROCEDURE BusyRemove;
- { BusyRemove uninstalls the busy cursor mechanism. Typically this is called once during
- program termination. It removes the VBL task and unpatches the patched traps. }
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-